package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.OrderTimeDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.Order;
import com.itheima.pojo.Setmeal;
import com.itheima.service.OrderTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = OrderTimeService.class)
@Transactional
public class OrderTimeServiceImpl implements OrderTimeService {

    @Autowired
    private OrderTimeDao orderTimeDao;

    @Override
    public int addOrder(Order order) {
        return orderTimeDao.addOrder(order);
    }

    @Override
    public PageResult selectOrder(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<Order> orderPage = orderTimeDao.selectOrder(queryPageBean);
        return new PageResult(orderPage.getTotal(),orderPage);
    }

    @Override
    public int deleteOrder(int id) {
        return orderTimeDao.deleteOrder(id);
    }

    @Override
    public Order selectOneOrder(int id) {
        return orderTimeDao.selectOneOrder(id);
    }

    @Override
    public List<Setmeal> selectStream() {
        return orderTimeDao.selectStream();
    }

    @Override
    public int updateOrder(Integer id,Order order) {
        orderTimeDao.updateStreamid(id,order.getId());
        return orderTimeDao.updateOrder(order);
    }




}
